% Using kFolds allows us to reduce the produced probabiltiy of error of our
% classification algorithm by dividing the same set of images into dynamic
% sets of training and validation sets

function [trainingSet, validationSet] = kFold( k , images, iteration)
 [~, n] = size(images); %get number of images
    startingIndex = ceil((((iteration - 1) * n) / k) + 1);
    endingIndex = ceil(((iteration * n) / k) - 1);
        
    validationSet = images(startingIndex : endingIndex);
    A = images(1 : startingIndex - 1);
    B = images(endingIndex + 1 : end);
    trainingSet = horzcat(A,B);
end

